package com.arvato.wxwork.service.staff;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.arvato.minipro.bean.bean_dto.common.PageData;
import com.arvato.minipro.bean.bean_dto.common.Query;
import com.arvato.wxwork.bean.bean_do.staff.WxworkPositionDo;
import com.arvato.wxwork.bean.bean_vo.staff.WxworkPositionVo;
import com.arvato.wxwork.mapper.staff.WxworkPositionMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;


@Service
@Transactional
public class WxworkPositionService {
	
	@Autowired
	private WxworkPositionMapper wxworkPositionMapper;
	
	/**
	 * 查询区域列表 分页查询
	 * @param query
	 * @param integer 
	 * @return
	 */
	public PageData listPositionByQuery(Query query, Integer pageNum, Integer pageSize) {
		// 设置分页参数
		PageHelper.startPage(pageNum, pageSize);
		List<WxworkPositionVo> areaList = wxworkPositionMapper.listPositionByQuery(query);
		PageInfo<WxworkPositionVo> pageInfo = new PageInfo<WxworkPositionVo>(areaList);
		PageData pageData = new PageData(pageInfo.getTotal(), pageInfo.getList());
		return pageData;
	}
	
	/**
	 * 根据ID查询详情
	 * @param areaId
	 * @return
	 */
	public WxworkPositionVo getPositionById(String areaId) {
		return wxworkPositionMapper.getPositionById(areaId);
	}
	
	/**
	 * 创建职位
	 * @param positionDo
	 */
	public int insert(WxworkPositionDo positionDo) {
		return wxworkPositionMapper.insert(positionDo);
	}
		
	/**
	 * 修改职位
	 * @param positionDo
	 * @return
	 */
	public int update(WxworkPositionDo positionDo) {
		return wxworkPositionMapper.update(positionDo);
	}
	/**
	 * 删除职位
	 * @param positionId
	 * @return
	 */
	public int delete(String positionId) {
		return wxworkPositionMapper.delete(positionId);
	}
	
}
